package com.zhangmeng.online.exam.entity;

import com.zhangmeng.online.exam.entity.baseEntity.BaseEntity;
import lombok.*;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

/** 试卷答案
 * @author zm
 * @date 2025/3/18 16:33
 * @version: 1.0
 */
@NoArgsConstructor
@ToString(exclude = {"questionOptions"})
@Getter
@Setter
@AllArgsConstructor
@Entity
@Table(name = "answer")
public class Answer extends BaseEntity<Long> {

    @ManyToOne(fetch = FetchType.LAZY)
    private PaperAnswer paperAnswer;

    @ManyToOne(fetch = FetchType.LAZY)
    private Question questions;//答案对应的题目

    @ManyToMany(fetch = FetchType.LAZY,targetEntity = QuestionOption.class)
    @JoinTable(name = "answer_question_option", joinColumns = @JoinColumn(name = "answer_id"), inverseJoinColumns = @JoinColumn(name = "option_id"))
    private List<QuestionOption> questionOptions = new ArrayList<>();

    private String answer;
}
